#include <stdio.h>
#include <string.h>

typedef struct {
    int day;
    char course[10];
} table;

int main() {
    FILE *fp;
    int i, fwi;
    table tab[3];

    tab[0].day = 1;
    strcpy(tab[0].course, "Chinese");
    tab[1].day = 2;
    strcpy(tab[1].course, "Maths");
    tab[2].day = 3;
    strcpy(tab[2].course, "Haha");

    fp = fopen(".\\test-data.txt", "wb+");
    if (fp == NULL) {
        printf("open file fail");
        return -1;
    }

    for (i = 0; i < 3; i++) {
        fwi = fwrite(&tab[i], sizeof(table), 1, fp);
        if (fwi != 1) {
            printf("tab[%d] write fail", i);
        }
    }

    fclose(fp);

    return 0;
}